using UnityEngine;

public class QDetail : MonoBehaviour
{
	private UIToggle curTog;

	private void Awake()
	{
		curTog = GetComponent<UIToggle>();
	}

	private void OnEnable()
	{
		if (QualityController.instance != null)
		{
			QualityController.onChangeQuality += UpdateParameter;
		}
		UpdateParameter();
	}

	private void OnDisable()
	{
		if (QualityController.instance != null)
		{
			QualityController.onChangeQuality -= UpdateParameter;
		}
	}

	public void ChangeQuality()
	{
		if (QualityController.instance != null)
		{
			QualityController.DetailLevel = curTog.value;
		}
	}

	private void UpdateParameter()
	{
		if (!(QualityController.instance != null))
		{
			return;
		}
		bool detailLevel = QualityController.DetailLevel;
		if (detailLevel != curTog.value)
		{
			curTog.value = detailLevel;
			if (BCWDebug.isDebugBuild)
			{
				BCWDebug.Log("UpdateParameter detail: " + detailLevel);
			}
		}
	}
}
